package org.cshoo.sys.command
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import mx.controls.Alert;
	import mx.rpc.IResponder;
	import mx.rpc.events.ResultEvent;
	
	import org.cshoo.sys.business.UserDelegate;
	import org.cshoo.sys.model.SysModelLocator;
	
	public class LogoutCommand implements ICommand, IResponder
	{
		
		private　var　_model:SysModelLocator = SysModelLocator.getInstance();
		
		public function LogoutCommand()
		{
		}
		
		public function execute(event:CairngormEvent):void
		{
			var userDelegate:UserDelegate = new UserDelegate(this);
			userDelegate.logout();
		}
		
		public function result(event:Object):void
		{
			var result:Boolean = (event as ResultEvent).result as Boolean;
			if(result){
				_model.currentUser = null;
			}
		}
		
		public function fault(info:Object):void
		{
			Alert.show("无法连接");
		}
	}
}